package Staff

import (
	"ali-hr/Services/Staff"
	"ali-hr/Util"
	"github.com/gin-gonic/gin"
	"strconv"
)

/**
 * Created by Goland
 * User: wkk alisleepy@hotmail.com
 * Time: 2023/1/8 - 16:43
 * Desc: <员工离职相关操作>
 */

// ResignList 辞职申请列表
func ResignList(c *gin.Context) {
	// get参数
	departmentId, _ := strconv.Atoi(c.Query("department_id"))
	name := c.Query("name")
	status := c.Query("status")
	pageIndex, _ := strconv.Atoi(c.Query("pageIndex"))
	pageSize, _ := strconv.Atoi(c.Query("pageSize"))

	var filters = make(map[string]interface{})
	filters["department_id"] = departmentId
	filters["name"] = name
	filters["status"] = status

	// 获取数据
	resignList, total, err := Staff.ResignList(pageIndex, pageSize, filters, false)
	if err != nil {
		Util.FailWithMessage("获取失败，请稍后再试", c)
		return
	}

	var result = make(map[string]interface{})
	result["data"] = resignList
	result["total"] = total
	Util.OkWithData(result, c)
}
